<?php

use swap\rdb_model;
use swap\visitor;

class resume_model extends rdb_model {
    
    const degree_user_info = 10; # 个人信息
    const degree_myself = 10; # 自我评价
    const degree_intention = 10; # 求职意向
    const degree_experience = 10; # 工作经验
    const degree_education = 10; # 教育背景
    const degree_training = 5; # 培训经历
    const degree_language = 5; # 语言能力
    const degree_letter = 5; # 求职信
    const degree_picture = 5; # 照片
    const degree_attachment = 0; # 附件
    const degree_certificate = 5; # 证书
    const degree_other = 5; # 兴趣爱好
    const degree_project = 10; # 项目经验
    const degree_skill = 10; # 专业技能
    const degree_study = 0; # 在校学习情况
    const degree_practice = 0; # 在校实践情况
    
    // training
    const name_length = 45;
    const address_length = 255;
    const course_length = 45;
    const certificate_length = 45;
    const introduction_length = 500;
    
    /**
     * array(
     *  'start_time' => array(),
     *  'end_time' => array(),
     * ) 
     */
    public static function prop_rules($operation) {
        $rules = array(
            'new' => '',
        );
        
        return $rules[$operation];
    }
    
    // 最新的简历
    public static function get_last_resume() {
        $last_resume = self::get(array('user_id' => visitor::get_role_id('user')), array(array('id' => 'desc'), 1, 1));
        return $last_resume === null ? null : current($last_resume);
    }
    
    public static function dec_resume_degree($id, $type) {
        $degree_key = 'degree_' . $type;
        $degree_value = constant('self::' . $degree_key);
        self::dec_by_id(array('degree' => $degree_value), $id);
    }
    public static function inc_resume_degree($id, $type) {
        $degree_key = 'degree_' . $type;
        $degree_value = constant('self::' . $degree_key);
        self::inc_by_id(array('degree' => $degree_value), $id);
    }
    public static function get_resume_degree($id) {
        $resume = resume_model::get_by_id($id);
        return $resume->degree;
    }
    
}